home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / flying-6.11 / object.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-30  |  1.8 KB  |  93 lines

  1. #ifndef _global_h
  2. #    include "global.h"
  3. #endif
  4.  
  5. #ifndef _object_h
  6. #    include "object.h"
  7. #endif
  8. #ifndef _ball_h
  9. #    include "ball.h"
  10. #endif
  11. #ifndef _graph_h
  12. #    include "graph.h"
  13. #endif
  14.  
  15. //
  16. // Statik der Object-Klasse
  17. //
  18. Object    *Object::stat_queue = 0l;        // globale Liste der statischen Obje
  19. int        Object::id_count = 0;            // aktuelle Objekt-Id
  20. Real        Object::min_time = MAX_TIME;    // Initialisierung
  21.  
  22.  
  23.  
  24. Object::Object() {
  25.     type   = UnknownObj;
  26.     id         = id_count++;
  27.     dyn_id = -1;
  28.     next     = stat_queue;        // alle Objekte zunaechst in statische Liste
  29.     stat_queue = this;
  30. }
  31.  
  32. Object::~Object() {
  33. Object    *last;
  34.  
  35.     if ( stat_queue == this )        stat_queue = next;
  36.     else {
  37.         last = stat_queue;        // Element aus Statik-Liste entfernen
  38.         while ( last->next && last->next != this )        last = last->next;
  39.         last->next = next;        // Element ausketten
  40.     }
  41. Object    *obj;
  42.     for (obj=stat_queue; obj; obj=obj->next ) {
  43.         if (obj->id>id)        obj->id--;    // Object-Ids neu nummerieren
  44.     }
  45.     id_count--;
  46. }
  47.  
  48. void Object::ForAll( ObjFun fun ) {
  49. Object *obj;
  50.  
  51.     for (obj=stat_queue; obj; obj=obj->next )     (obj->*fun)();
  52. }
  53.  
  54.  
  55. Real Object::Collision()        { return NO_HIT;    }
  56.  
  57. void Object::WasHit(Object*)    { }
  58.  
  59. void Object::Info() {
  60.     printf( "%02d: Static:     %08lx\n", id, (unsigned long)this );
  61. }
  62.  
  63. void Object::Draw() {
  64. #if (0)
  65.     switch(type) {
  66.     case StaticArcObj:
  67.         StaticArc    *p = this;
  68.         DrawArc( p->P(), p->r, p->start, p->angle );
  69.         break;
  70.     case StaticBallObj:
  71.         StaticBall    *p = this
  72.         DrawCircle( p->P(), p->R() );
  73.         break;
  74.     case WallObj:
  75.         Wall            *p = this;
  76.         DrawLine( p->p1, p->p2 );
  77.         break;
  78.     case PocketObj:
  79.         Pocket        *p = this;
  80. #ifndef __TURBOC__
  81.         XSetLineAttributes(dpy,*ga,0,LineOnOffDash,CapRound,JoinRound);
  82. #endif
  83.         DrawCircle( p->P(), p->R() );
  84. #ifndef __TURBOC__
  85.         XSetLineAttributes(dpy,*ga,0,LineSolid,CapRound,JoinRound);
  86. #endif
  87.         break;
  88.     case UnknownObj:
  89.         break;
  90.     }
  91. #endif
  92. }
  93.